<html xmlns:th="https://www.thymeleaf.org" xmlns:layout="https://github.com/ultraq/thymeleaf-layout-dialect" layout:decorate="~{layout}">
<head>
	<title>Secured Content</title>
</head>
<body>
	<div layout:fragment="content">
		<h1>Secured Page</h1>
		<p>This page is secured using Spring Boot, Spring Session, and Spring Security.</p>

		<p>Your current session id is <span id="session-id" th:text="${#httpSession.id}"></span></p>

		<table class="table table-stripped">
			<tr>
				<th>Id Suffix</th>
				<th>Location</th>
				<th>Created</th>
				<th>Last Updated</th>
				<th>Information</th>
				<th>Terminate</th>
			</tr>
			<tr th:each="sessionElement : ${sessions}" th:with="details=${sessionElement.getAttribute('SESSION_DETAILS')}">
				<td th:text="${sessionElement.id.substring(30)}"></td>
				<td th:text="${details?.location}"></td>
				<td th:text="${#temporals.format(sessionElement.creationTime.atZone(T(java.time.ZoneId).systemDefault()),'dd/MMM/yyyy HH:mm:ss')}"></td>
				<td th:text="${#temporals.format(sessionElement.lastAccessedTime.atZone(T(java.time.ZoneId).systemDefault()),'dd/MMM/yyyy HH:mm:ss')}"></td>
				<td th:text="${details?.accessType}"></td>
				<td>
					<form th:action="@{'/sessions/' + ${sessionElement.id}}" th:method="post">
						<input th:id="'terminate-' + ${sessionElement.id}" type="submit" value="Terminate" th:disabled="${sessionElement.id == #httpSession.id}"/>
					</form>
				</td>
			</tr>
		</table>
	</div>
</body>
</html>
